<!--
 * @Author: your name
 * @Date: 2021-08-03 13:36:05
 * @LastEditTime: 2021-08-05 15:25:02
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \getHome (2)\src\components\discounts\amend.vue
-->
<!--配置优惠券-->
<template>
  <el-table style="width: 100%" max-height="250" :data="ArrData">
    <el-button style="color: #fc9e76;" type="text"
      >点击打开 Message Box</el-button
    >

    <el-table-column label="优惠券名称" prop="couponTitle"></el-table-column>
    <el-table-column label="使用条件" prop="useConditions">
      <template slot-scope="scope">
        <div>
          {{ scope.row.useConditions == 1 ? "固定模式" : "循环叠加模式" }}
        </div>
      </template>
    </el-table-column>
    <el-table-column label="发放数量" prop="sendQuantity"></el-table-column>

    <el-table-column label="有效期" prop="time">
      <template slot-scope="scope">
        <div>
          {{ scope.row.effectiveStartTime }}-
          {{ scope.row.effectiveEndTime }}
        </div>
      </template>
    </el-table-column>

    <el-table-column fixed="right" label="操作">
      <template slot-scope="scope">
        <el-button
          @click.native.prevent="
            deleteRow(scope.$index, ArrData, scope.row.couponNo)
          "
          style="color: #fc9e76;"
          type="text"
          size="small"
        >
          删除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  name: "ConfigCouponList",
  //声明接收"ArrData", "deleteTodo"
  props: ["ArrData", "deleteTodo"],

  data() {
    return {
      tableData: JSON.parse(localStorage.getItem("tableData")) || []
    };
  },

  methods: {
    deleteRow(index, rows, couponNo) {
      this.deleteTodo(index, rows, couponNo);
    }
  },
  watch: {
    tableData: {
      deep: true,
      handler(value) {
        console.log("value,,,,1,,", value);
        localStorage.setItem("tableData", JSON.stringify(value));
        console.log("value,,2,,,,", value);
      }
    }
  }
};
</script>
